package com.netrust.cmsx.entity.module.site;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.*;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.netrust.cmsx.entity.module.sys.Role;

/**
 * @title 前台用户管理
 * @description 根据用户id获取用户信息
 * @author ZYC
 * @version v_1.0.0
 * @date 2017年6月13日 下午4:10:20
 */
@Entity
@Table(name = "t_site_user")
public class SiteUser implements Serializable {

	private static final long serialVersionUID = -2440407615662318499L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY) // IDENTITY：主键由数据库自动生成（主要是自动增长型）
	@Column(name = "u_id", unique = true, nullable = false)
	private Integer id;// id主键

	@Column(name = "u_account", nullable = false)
	private String account;// 登陆账号

	@Column(name = "u_password")
	private String password;// 密码

	@Column(name = "u_state")
	private Integer state;// 用户状态

	@Column(name = "u_login_time")
	private Timestamp loginTime;// 最后登陆时间

	@Column(name = "u_phone")
	private String phone;// 联系方式

	@Column(name = "u_salt")
	private String salt;// 盐

	@Column(name = "dg_id", nullable = false)
	private Integer dgId;// dg_id栏目分组ID，外键系统字典组表

	@Column(name = "di_id", nullable = false)
	private Integer diId;// di_id栏目分组值，外键系统字典项表

	@Transient
	private Set<Role> roles = new HashSet<Role>();

	@JsonIgnore
	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "t_site_user_role", joinColumns = @JoinColumn(name = "t_su_id"), inverseJoinColumns = @JoinColumn(name = "t_r_id"))
	private Set<Role> iRoles = new HashSet<Role>();

	public SiteUser() {
		super();
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Integer getState() {
		return state;
	}

	public void setState(Integer state) {
		this.state = state;
	}

	public Timestamp getLoginTime() {
		return loginTime;
	}

	public void setLoginTime(Timestamp loginTime) {
		this.loginTime = loginTime;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getSalt() {
		return salt;
	}

	public void setSalt(String salt) {
		this.salt = salt;
	}

	public Integer getDgId() {
		return dgId;
	}

	public void setDgId(Integer dgId) {
		this.dgId = dgId;
	}

	public Integer getDiId() {
		return diId;
	}

	public void setDiId(Integer diId) {
		this.diId = diId;
	}

	public Set<Role> getRoles() {
		return roles;
	}

	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

	public Set<Role> getiRoles() {
		return iRoles;
	}

	public void setiRoles(Set<Role> iRoles) {
		this.iRoles = iRoles;
	}

}
